<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
    <!--组件的定义-局部组件和全局组件-->
    <div id="app">
       <mycomponent></mycomponent>
       <mycomponent2></mycomponent2>
    </div>
    <script>
        var mycomponent2={
            template:`
            <div>
                <h2>{{content}}</h2>
             </div>   
            `,
            data(){
                return{
                    content:'hello component2'
                }
            }
        }
        //全局组件
        Vue.component('mycomponent',{
            template:`
            <div>
                <h2>{{content}}</h2>
             </div>   
            `,
            data(){
                return{
                    content:'hello component'
                }
            }
        })
        //根组件
        var app=new Vue({
            el:'#app',
            components:{
                mycomponent2
            }
        })
    </script>
</body>
</html>